package jia.game;

import jia.core.GameStateManager;

import javax.swing.*;
import java.awt.*;
import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: stelle
 * Date: Jan 24, 2006
 * Time: 11:41:28 AM
 * To change this template use File | Settings | File Templates.
 */
public class ModuleInfoPanel extends JPanel{
    private JLabel xyPos = new JLabel();
    private JLabel gameTime = new JLabel();
    private GameStateManager mgr;
    
    public ModuleInfoPanel(){
        init();
    }
    
    private void init(){
        this.setSize(347, 68);
        this.setLayout(new GridLayout(2, 1));
        this.setVisible(true);
        this.setBackground(ComponentUtils.getGlobalBackgroundColor());
        this.setFocusable(false);
        xyPos.setForeground(ComponentUtils.getGlobalForegroundColor());
        xyPos.setFont(ComponentUtils.getGlobalFont());
        xyPos.setVisible(true);
        xyPos.setSize(this.getWidth(), this.getHeight() / 2);
        gameTime.setForeground(ComponentUtils.getGlobalForegroundColor());
        gameTime.setFont(ComponentUtils.getGlobalFont());
        gameTime.setVisible(true);
        gameTime.setSize(this.getWidth(), this.getHeight() / 2);
        this.add(xyPos);
        this.add(gameTime);
    }
    
    /**
     * @param gameState
     */
    public void registerGameState(GameStateManager gameState){
        mgr = gameState;
    }
    
    /**
     * @param gameState
     */
    public void updateGameState(GameStateManager gameState){
        this.mgr = gameState;
        this.xyPos.setText(Double.toString(gameState.getPlayerState().getPosition().x) + ", " + Double.toString(gameState.getPlayerState().getPosition().y));
        this.gameTime.setText(Calendar.HOUR + ":" + Calendar.MINUTE);
    }
}
